var e = require("../../../../../@babel/runtime/helpers/regeneratorRuntime"), t = require("../../../../../@babel/runtime/helpers/asyncToGenerator"), i = require("../../../../../@babel/runtime/helpers/objectSpread2"), o = require("../../../../../common/vendor.js"), n = require("./z-paging-static.js"), r = require("./z-paging-constant.js"), s = require("./z-paging-utils.js"), a = require("./modules/common-layout.js"), u = require("./modules/data-handle.js"), l = require("./modules/i18n.js"), c = require("./modules/nvue.js"), h = require("./modules/empty.js"), d = require("./modules/refresher.js"), g = require("./modules/load-more.js"), f = require("./modules/loading.js"), p = require("./modules/scroller.js"), m = require("./modules/back-to-top.js"), y = require("./modules/virtual-list.js"), S = require("./z-paging-enum.js"), b = o.index.getSystemInfoSync(), x = {
    name: "z-paging",
    components: {
        zPagingRefresh: function() {
            return "../components/z-paging-refresh.js";
        },
        zPagingLoadMore: function() {
            return "../components/z-paging-load-more.js";
        },
        zPagingEmptyView: function() {
            return "../../z-paging-empty-view/z-paging-empty-view.js";
        }
    },
    mixins: [ a.commonLayoutModule, u.dataHandleModule, l.i18nModule, c.nvueModule, h.emptyModule, d.refresherModule, g.loadMoreModule, f.loadingModule, p.scrollerModule, m.backToTopModule, y.virtualListModule ],
    data: function() {
        return {
            base64Arrow: n.zStatic.base64Arrow,
            base64Flower: n.zStatic.base64Flower,
            base64BackToTop: n.zStatic.base64BackToTop,
            loadingType: S.Enum.LoadingType.Refresher,
            requestTimeStamp: 0,
            chatRecordLoadingMoreText: "",
            wxsPropType: "",
            renderPropScrollTop: -1,
            checkScrolledToBottomTimeOut: null,
            cacheTopHeight: -1,
            statusBarHeight: b.statusBarHeight,
            insideOfPaging: -1,
            isLoadFailed: !1,
            isIos: "ios" === b.platform,
            disabledBounce: !1,
            fromCompleteEmit: !1,
            disabledCompleteEmit: !1,
            pageLaunched: !1,
            wxsIsScrollTopInTopRange: !0,
            wxsScrollTop: 0,
            wxsPageScrollTop: 0,
            wxsOnPullingDown: !1
        };
    },
    props: {
        delay: {
            type: [ Number, String ],
            default: s.u.gc("delay", 0)
        },
        minDelay: {
            type: [ Number, String ],
            default: s.u.gc("minDelay", 0)
        },
        pagingStyle: {
            type: Object,
            default: function() {
                return s.u.gc("pagingStyle", {});
            }
        },
        height: {
            type: String,
            default: s.u.gc("height", "")
        },
        width: {
            type: String,
            default: s.u.gc("width", "")
        },
        bgColor: {
            type: String,
            default: s.u.gc("bgColor", "")
        },
        pagingContentStyle: {
            type: Object,
            default: function() {
                return s.u.gc("pagingContentStyle", {});
            }
        },
        autoHeight: {
            type: Boolean,
            default: s.u.gc("autoHeight", !1)
        },
        autoHeightAddition: {
            type: [ Number, String ],
            default: s.u.gc("autoHeightAddition", "0px")
        },
        defaultThemeStyle: {
            type: String,
            default: s.u.gc("defaultThemeStyle", "black")
        },
        fixed: {
            type: Boolean,
            default: s.u.gc("fixed", !0)
        },
        safeAreaInsetBottom: {
            type: Boolean,
            default: s.u.gc("safeAreaInsetBottom", !1)
        },
        useSafeAreaPlaceholder: {
            type: Boolean,
            default: s.u.gc("useSafeAreaPlaceholder", !1)
        },
        topZIndex: {
            type: Number,
            default: s.u.gc("topZIndex", 99)
        },
        superContentZIndex: {
            type: Number,
            default: s.u.gc("superContentZIndex", 1)
        },
        contentZIndex: {
            type: Number,
            default: s.u.gc("contentZIndex", 10)
        },
        autoFullHeight: {
            type: Boolean,
            default: s.u.gc("autoFullHeight", !0)
        },
        watchTouchDirectionChange: {
            type: Boolean,
            default: s.u.gc("watchTouchDirectionChange", !1)
        }
    },
    created: function() {
        this.createdReload && !this.refresherOnly && this.auto && (this._startLoading(), 
        this.$nextTick(this._preReload));
    },
    mounted: function() {
        var e = this;
        this.wxsPropType = s.u.getTime().toString(), this.renderJsIgnore, this.createdReload || this.refresherOnly || !this.auto || this.$nextTick(this._preReload), 
        this.finalUseCache && this._setListByLocalCache();
        var t;
        t = r.c.delayTime, this.$nextTick(function() {
            e.systemInfo = o.index.getSystemInfoSync(), !e.usePageScroll && e.autoHeight && e._setAutoHeight(), 
            e.loaded = !0, s.u.delay(e.updateFixedLayout);
        }), this.updatePageScrollTopHeight(), this.updatePageScrollBottomHeight(), this.updateLeftAndRightWidth(), 
        this.finalRefresherEnabled && this.useCustomRefresher && this.$nextTick(function() {
            e.isTouchmoving = !0;
        }), this._onEmit(), this.finalUseVirtualList && this._virtualListInit(), this.$nextTick(function() {
            setTimeout(function() {
                e._getCssSafeAreaInsetBottom(function() {
                    return e.safeAreaInsetBottom && e.updatePageScrollBottomHeight();
                });
            }, t);
        });
    },
    destroyed: function() {
        this._offEmit();
    },
    unmounted: function() {
        this._offEmit();
    },
    watch: {
        defaultThemeStyle: {
            handler: function(e) {
                e.length && (this.finalRefresherDefaultStyle = e);
            },
            immediate: !0
        },
        autoHeight: function(e) {
            this.loaded && !this.usePageScroll && this._setAutoHeight(e);
        },
        autoHeightAddition: function(e) {
            this.loaded && !this.usePageScroll && this.autoHeight && this._setAutoHeight(e);
        }
    },
    computed: {
        finalPagingStyle: function() {
            var e = i({}, this.pagingStyle);
            if (!this.systemInfo) return e;
            var t = this.windowTop, o = this.windowBottom;
            return !this.usePageScroll && this.fixed && (t && !e.top && (e.top = t + "px"), 
            o && !e.bottom && (e.bottom = o + "px")), this.bgColor.length && !e.background && (e.background = this.bgColor), 
            this.height.length && !e.height && (e.height = this.height), this.width.length && !e.width && (e.width = this.width), 
            e;
        },
        finalLowerThreshold: function() {
            return s.u.convertToPx(this.lowerThreshold);
        },
        finalPagingContentStyle: function() {
            return 1 != this.contentZIndex && (this.pagingContentStyle["z-index"] = this.contentZIndex, 
            this.pagingContentStyle.position = "relative"), this.pagingContentStyle;
        },
        renderJsIgnore: function() {
            var e = this;
            return (this.usePageScroll && this.useChatRecordMode || !this.refresherEnabled && this.scrollable || !this.useCustomRefresher) && this.$nextTick(function() {
                e.renderPropScrollTop = 10;
            }), 0;
        },
        windowHeight: function() {
            return this.systemInfo && this.systemInfo.windowHeight || 0;
        },
        windowBottom: function() {
            if (!this.systemInfo) return 0;
            var e = this.systemInfo.windowBottom || 0;
            return this.safeAreaInsetBottom && !this.useSafeAreaPlaceholder && (e += this.safeAreaBottom), 
            e;
        },
        isIosAndH5: function() {
            return !1;
        }
    },
    methods: {
        getVersion: function() {
            return "z-paging v".concat(r.c.version);
        },
        setSpecialEffects: function(e) {
            this.setListSpecialEffects(e);
        },
        setListSpecialEffects: function(e) {
            this.nFixFreezing = e && Object.keys(e).length, this.isIos && (this.privateRefresherEnabled = 0), 
            !this.usePageScroll && this.$refs["zp-n-list"].setSpecialEffects(e);
        },
        _doVibrateShort: function() {
            o.index.vibrateShort();
        },
        _setAutoHeight: function() {
            var i = arguments, o = this;
            return t(e().mark(function t() {
                var n, r, a, u, l, c, h, d;
                return e().wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        if (n = !(i.length > 0 && void 0 !== i[0]) || i[0], r = i.length > 1 && void 0 !== i[1] ? i[1] : null, 
                        a = "min-height", a = "min-height", e.prev = 4, !n) {
                            e.next = 18;
                            break;
                        }
                        if (e.t0 = r, e.t0) {
                            e.next = 11;
                            break;
                        }
                        return e.next = 10, o._getNodeClientRect(".zp-scroll-view");

                      case 10:
                        e.t0 = e.sent;

                      case 11:
                        return u = e.t0, e.next = 14, o._getNodeClientRect(".zp-page-bottom");

                      case 14:
                        l = e.sent, u && (c = u[0].top, h = o.windowHeight - c, h -= l ? l[0].height : 0, 
                        d = h + s.u.convertToPx(o.autoHeightAddition) - (o.insideMore ? 1 : 0) + "px !important", 
                        o.$set(o.scrollViewStyle, a, d), o.$set(o.scrollViewInStyle, a, d)), e.next = 19;
                        break;

                      case 18:
                        o.$delete(o.scrollViewStyle, a), o.$delete(o.scrollViewInStyle, a);

                      case 19:
                        e.next = 23;
                        break;

                      case 21:
                        e.prev = 21, e.t1 = e.catch(4);

                      case 23:
                      case "end":
                        return e.stop();
                    }
                }, t, null, [ [ 4, 21 ] ]);
            }))();
        },
        _updateInsideOfPaging: function() {
            this.insideMore && !0 === this.insideOfPaging && setTimeout(this.doLoadMore, 200);
        },
        _cleanTimeout: function(e) {
            return e && (clearTimeout(e), e = null), e;
        },
        _onEmit: function() {
            var e = this;
            o.index.$on(r.c.errorUpdateKey, function(t) {
                e.loading && (t && (e.customerEmptyViewErrorText = t), e.complete(!1).catch(function() {}));
            }), o.index.$on(r.c.completeUpdateKey, function(t) {
                setTimeout(function() {
                    if (e.loading) if (e.disabledCompleteEmit) e.disabledCompleteEmit = !1; else {
                        var i = t.type || "normal", o = t.list || t, n = t.rule;
                        switch (e.fromCompleteEmit = !0, i) {
                          case "normal":
                            e.complete(o);
                            break;

                          case "total":
                            e.completeByTotal(o, n);
                            break;

                          case "nomore":
                            e.completeByNoMore(o, n);
                            break;

                          case "key":
                            e.completeByKey(o, n);
                        }
                    }
                }, 1);
            });
        },
        _offEmit: function() {
            o.index.$off(r.c.errorUpdateKey), o.index.$off(r.c.completeUpdateKey);
        }
    }
};

exports._sfc_main = x;